import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSEditor } from '../ipseditor';
import { IPSDEForm } from './ipsdeform';
import { IPSDEFormItem } from './ipsdeform-item';
import { IPSDEFormItemUpdate } from './ipsdeform-item-update';
import { PSDEFormDetailImpl } from './psdeform-detail-impl';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysImage } from '../../res/ipssys-image';

export class PSDEFormItemImpl extends PSDEFormDetailImpl implements IPSDEFormItem {
  get caption(): string {
    return this.M.caption;
  }

  get captionItemName(): string {
    return this.M.captionItemName;
  }

  get createDV(): string {
    return this.M.createDV;
  }

  get createDVT(): 'SESSION' | 'APPLICATION' | 'UNIQUEID' | 'CONTEXT' | 'PARAM' | 'OPERATOR' | 'OPERATORNAME' | 'CURTIME' | 'APPDATA' {
    return this.M.createDVT;
  }

  get dataType(): 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 {
    return this.M.dataType;
  }

  get enableCond(): 0 | 1 | 2 | 3 {
    return this.M.enableCond;
  }

  get fieldName(): string {
    return this.M.fieldName;
  }

  get ignoreInput(): number {
    return this.M.ignoreInput;
  }

  get inputTip(): string {
    return this.M.inputTip;
  }

  get inputTipUrl(): string {
    return this.M.inputTipUrl;
  }

  get itemHeight(): number {
    return this.M.itemHeight != null ? this.M.itemHeight : 0.0;
  }

  get itemWidth(): number {
    return this.M.itemWidth != null ? this.M.itemWidth : 0.0;
  }

  get labelCssStyle(): string {
    return this.M.labelCssStyle;
  }

  get labelDynaClass(): string {
    return this.M.labelDynaClass;
  }

  get labelPos(): 'LEFT' | 'TOP' | 'RIGHT' | 'BOTTOM' | 'NONE' {
    return this.M.labelPos;
  }

  get labelWidth(): number {
    return this.M.labelWidth;
  }

  get noPrivDisplayMode(): 1 | 2 {
    return this.M.noPrivDisplayMode;
  }

  get outputCodeListConfigMode(): 0 | 1 | 2 {
    return this.M.outputCodeListConfigMode != null ? this.M.outputCodeListConfigMode : 0;
  }

  protected phpslanguageres: IPSLanguageRes | null = null;

  getPHPSLanguageRes(): IPSLanguageRes | null {
    if (this.phpslanguageres != null) return this.phpslanguageres;
    const value = this.M.getPHPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.phpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getPHPSLanguageRes') as IPSLanguageRes;
    return this.phpslanguageres;
  }

  get pHPSLanguageRes(): IPSLanguageRes | null {
    return this.getPHPSLanguageRes();
  }

  getPHPSLanguageResMust(): IPSLanguageRes {
    const value = this.getPHPSLanguageRes();
    if (value == null) {
      throw new Error('未指定输入提示语言资源');
    }
    return value;
  }

  protected psappdefield: IPSAppDEField | null = null;

  getPSAppDEField(): IPSAppDEField | null {
    if (this.psappdefield != null) return this.psappdefield;
    const value = this.M.getPSAppDEField;
    if (value == null) {
      return null;
    }
    this.psappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getPSAppDEField') as IPSAppDEField;
    return this.psappdefield;
  }

  get psAppDEField(): IPSAppDEField | null {
    return this.getPSAppDEField();
  }

  getPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getPSAppDEField();
    if (value == null) {
      throw new Error('未指定应用实体属性');
    }
    return value;
  }

  protected psdeformitemupdate: IPSDEFormItemUpdate | null = null;

  getPSDEFormItemUpdate(): IPSDEFormItemUpdate | null {
    if (this.psdeformitemupdate != null) return this.psdeformitemupdate;
    const value = this.M.getPSDEFormItemUpdate;
    if (value == null) {
      return null;
    }
    const ipsdeform = this.getParentPSModelObject('control.form.IPSDEForm') as IPSDEForm;
    if (ipsdeform != null) {
      this.psdeformitemupdate = ipsdeform.findPSDEFormItemUpdate(value);
    }
    return this.psdeformitemupdate;
  }

  get psDEFormItemUpdate(): IPSDEFormItemUpdate | null {
    return this.getPSDEFormItemUpdate();
  }

  getPSDEFormItemUpdateMust(): IPSDEFormItemUpdate {
    const value = this.getPSDEFormItemUpdate();
    if (value == null) {
      throw new Error('未指定表单项更新');
    }
    return value;
  }

  protected pseditor: IPSEditor | null = null;

  getPSEditor(): IPSEditor | null {
    if (this.pseditor != null) return this.pseditor;
    const value = this.M.getPSEditor;
    if (value == null) {
      return null;
    }
    this.pseditor = this.getPSModel4('control.IPSEditor', value, 'getPSEditor') as IPSEditor;
    return this.pseditor;
  }

  get psEditor(): IPSEditor | null {
    return this.getPSEditor();
  }

  getPSEditorMust(): IPSEditor {
    const value = this.getPSEditor();
    if (value == null) {
      throw new Error('未指定编辑器对象');
    }
    return value;
  }

  protected pssysimage: IPSSysImage | null = null;

  getPSSysImage(): IPSSysImage | null {
    if (this.pssysimage != null) return this.pssysimage;
    const value = this.M.getPSSysImage;
    if (value == null) {
      return null;
    }
    this.pssysimage = this.getPSModel4('res.IPSSysImage', value, 'getPSSysImage') as IPSSysImage;
    return this.pssysimage;
  }

  get psSysImage(): IPSSysImage | null {
    return this.getPSSysImage();
  }

  getPSSysImageMust(): IPSSysImage {
    const value = this.getPSSysImage();
    if (value == null) {
      throw new Error('未指定表单项图片对象');
    }
    return value;
  }

  get resetItemName(): string {
    return this.M.resetItemName;
  }

  protected resetitemnames: string[] | null = null;

  getResetItemNames(): string[] | null {
    if (this.resetitemnames == null) {
      const value = this.M.resetItemNames;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: string[] = [];
      for (let i = 0; i < arrayNode.length; i++) {
        list.push(arrayNode[i]);
      }
      this.resetitemnames = list;
    }
    return this.resetitemnames.length == 0 ? null : this.resetitemnames;
  }

  get resetItemNames(): string[] | null {
    return this.getResetItemNames();
  }

  get unitName(): string {
    return this.M.unitName;
  }

  get unitNameWidth(): number {
    return this.M.unitNameWidth != null ? this.M.unitNameWidth : 0;
  }

  get updateDV(): string {
    return this.M.updateDV;
  }

  get updateDVT(): 'SESSION' | 'APPLICATION' | 'UNIQUEID' | 'CONTEXT' | 'PARAM' | 'OPERATOR' | 'OPERATORNAME' | 'CURTIME' | 'APPDATA' {
    return this.M.updateDVT;
  }

  get valueFormat(): string {
    return this.M.valueFormat;
  }

  get valueItemName(): string {
    return this.M.valueItemName;
  }

  get allowEmpty(): boolean {
    return this.M.allowEmpty;
  }

  get compositeItem(): boolean {
    return this.M.compositeItem != null ? this.M.compositeItem : false;
  }

  get convertToCodeItemText(): boolean {
    return this.M.convertToCodeItemText != null ? this.M.convertToCodeItemText : false;
  }

  get emptyCaption(): boolean {
    return this.M.emptyCaption != null ? this.M.emptyCaption : false;
  }

  get enableAnchor(): boolean {
    return this.M.enableAnchor != null ? this.M.enableAnchor : false;
  }

  get enableInputTip(): boolean {
    return this.M.enableInputTip != null ? this.M.enableInputTip : false;
  }

  get enableItemPriv(): boolean {
    return this.M.enableItemPriv != null ? this.M.enableItemPriv : false;
  }

  get enableUnitName(): boolean {
    return this.M.enableUnitName != null ? this.M.enableUnitName : false;
  }

  get hidden(): boolean {
    return this.M.hidden != null ? this.M.hidden : false;
  }

  get inputTipClosable(): boolean {
    return this.M.inputTipClosable != null ? this.M.inputTipClosable : false;
  }

  get needCodeListConfig(): boolean {
    return this.M.needCodeListConfig != null ? this.M.needCodeListConfig : false;
  }

  get showCaption(): boolean {
    return this.M.showCaption != null ? this.M.showCaption : false;
  }

  get cls(): string {
    return 'PSDEFormItemImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.form.IPSDEFormItem') return true;
    return super.instanceof(cls);
  }
}
